<template>
	<view class="container">
		<Navigator2 :title="$t('device.deviceSettingGuide')"></Navigator2>
		
		<!-- 步骤指示器 -->
		<view class="step-indicator">
			<view class="step-item">
				<view class="step-circle active">1</view>
				<text class="step-text active">{{ $t('device.devicePowerOn') }}</text>
			</view>
			<view class="step-line"></view>
			<view class="step-item">
				<view class="step-circle">2</view>
				<text class="step-text">{{ $t('device.connectDevice') }}</text>
			</view>
			<view class="step-line"></view>
			<view class="step-item">
				<view class="step-circle">3</view>
				<text class="step-text">{{ $t('device.connectNetwork') }}</text>
			</view>
		</view>
		
		<!-- 设备图片 -->
		<view class="device-image">
			<image src="/static/guide-doll.png" mode="aspectFit"></image>
		</view>
		
		<!-- 设备上电说明 -->
		<view class="guide-content">
			<view class="guide-title">
				<image src="/static/guide-thunder.png" class="title-icon" mode="aspectFit"></image>
				<text>{{ $t('device.devicePowerOn') }}</text>
			</view>
			
			<view class="guide-steps">
				<text class="step-text">1. {{ $t('device.placeDeviceOnStableSurface') }}</text>
				<text class="step-text">2. {{ $t('device.findPowerInterface') }}</text>
				<text class="step-text">3. {{ $t('device.connectPowerAdapter') }}</text>
				<text class="step-text">4. {{ $t('device.pressPowerButton') }}</text>
				<view class="step-text">
					<image src="/static/light.png" style="width: 8px; height: 8px;"></image>
					<text style="margin-left: 8px;color: #1F9940;font-size: 14px;font-weight: 400;line-height: 22px;">{{ $t('device.lightOn') }}</text>
				</view>
			</view>
		</view>
		
		<!-- 底部固定区域 -->
		<view class="bottom-section">
			<!-- 确认勾选 -->
			<view class="confirm-section">
				<view class="checkbox" :class="{checked: isConfirmed}" @click="toggleConfirm">
					<text class="checkmark" v-if="isConfirmed">✓</text>
				</view>
				<text class="confirm-text" @click="toggleConfirm">{{ $t('device.iHaveConfirmedTheAboveOperations') }}</text>
			</view>
			
			<!-- 下一步按钮 -->
			<view class="next-button" :class="{disabled: !isConfirmed}" @click="nextStep">
				<text>{{ $t('device.nextStep') }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import Navigator2 from '@/components/Navigator2.vue'
	export default {
		data() {
			return {
				isConfirmed: false
			}
		},
		methods: {
			toggleConfirm() {
				this.isConfirmed = !this.isConfirmed
			},
			nextStep() {
				if (!this.isConfirmed) return
				// 跳转到下一步
				uni.navigateTo({
					url: '/pages/device/devicesettingguide2'
				})
			}
		},
		components: {
			Navigator2
		}
	}
</script>

<style lang="scss" scoped>
.container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
}

.bottom-section {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: white;
	padding-top: 20rpx;
}

.step-indicator {
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 40rpx 80rpx;
	margin-bottom: 16px;
	
	.step-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		flex-shrink: 0;
		position: relative;

		.step-circle {
			width: 32px;
			height: 32px;
			border-radius: 50%;
			background: #EBEFF4;
			color: #6B7280;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 14px;
			font-weight: bold;

			&.active {
				background: #0256FF;
				color: white;
			}
		}

		.step-text {
			position: absolute;
			top: 52px;
			left: 50%;
			transform: translateX(-50%);
			font-size: 24rpx;
			color: #707A89;
			white-space: nowrap;
			text-align: center;

			&.active {
				color: #0256FF;
				font-weight: 500;
			}
		}
	}
	
	.step-line {
		width: 100rpx;
		height: 2rpx;
		background: #e0e0e0;
		margin: 0 20rpx;
		margin-top: 16px;
		flex-shrink: 0;
	}
}

.device-image {
	display: flex;
	justify-content: center;
	align-items: center;
	padding: 10px;
	border-radius: 32px;
	background: #EDEFF6;
	width: fit-content;
	margin: 0 auto;
	margin-top: 40px;
	margin-bottom: 40px;
	
	image {
		width: 150px;
		height: 150px;
	}
}

.guide-content {
	padding: 0 60rpx 220rpx;
	
	.guide-title {
		display: flex;
		align-items: center;
		margin-bottom: 40rpx;
		
		.title-icon {
			width: 18.57px;
			height: 18.57px;
			margin-right: 20rpx;
		}
		
		text {
			font-size: 16px;
			font-weight: 600;
			color: #1F2937;
		}
	}
	
	.guide-steps {
		.step-text {
			display: block;
			font-size: 28rpx;
			color: #000000;
			line-height: 44rpx;
			margin-bottom: 20rpx;
		}
		
		.success-tip {
			display: flex;
			align-items: center;
			margin-top: 30rpx;
			
			.success-dot {
				color: #4caf50;
				font-size: 40rpx;
				margin-right: 16rpx;
			}
			
			.success-text {
				font-size: 28rpx;
				color: #4caf50;
			}
		}
		.guide-step-desc {
			width: 216px;
			height: 22px;
		}
	}
}

.confirm-section {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40rpx 60rpx 20rpx;
	
	.checkbox {
		width: 16px;
		height: 16px;
		border: 2rpx solid #0256FF;
		border-radius: 50%;
		margin-right: 20rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		
		&.checked {
			background: #0256FF;
		}
		
		.checkmark {
			color: white;
			font-size: 24rpx;
			font-weight: bold;
		}
	}
	
	.confirm-text {
		font-size: 28rpx;
		color: #333;
	}
}

.next-button {
	margin: 40rpx 60rpx 40rpx;
	height: 100rpx;
	background: #0256FF;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	
	&.disabled {
		background: #ccc;
	}

	&:active:not(.disabled) {
		background: #0245ff;
	}
	
	text {
		color: white;
		font-size: 32rpx;
	}
}
</style>
